<template>
  <div v-if="tableData.length> 0" class="item-menu-main test-report">
    <div class="item-menu-header">
      <h4>{{ oneItemMenu.itemName }}</h4>
    </div>
    <el-table
      :data="tableData"
      stripe
    >
      <el-table-column
        prop="zbxmmc"
        label="项目名称"
        min-width="180"
      />
      <!--      <el-table-column-->
      <!--        prop="zbxmbm"-->
      <!--        label="英文名"-->
      <!--        min-width="180"-->
      <!--      />-->
      <el-table-column
        prop="jyjgz"
        label="结果"
        min-width="120"
      />
      <el-table-column
        prop="ycbz"
        label="偏"
        min-width="60"
      />
      <el-table-column
        prop="dxzb"
        label="参考区间"
        min-width="120"
      />
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
      @pagination="getList"
    />
  </div>
  <div v-else>
    <el-empty description="暂无数据" />
  </div>
</template>

<script>
import Pagination from '@/components/Pagination'
import { getPatientExamRegistrationInfoCheckList } from '@/api/patientDetails'
export default {
  name: 'TestReport',
  components: {
    Pagination
  },
  props: {
    oneItemMenu: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      tableData: [],
      loading: false,
      listQuery: {
        limit: 10,
        page: 1
      },
      total: 0
    }
  },
  watch: {
    oneItemMenu: {
      handler() {
        if (this.oneItemMenu.bgbh !== undefined) {
          this.getPatientExamRegistrationInfoCheckList({
            // bgbh: '008',
            bgbh: this.oneItemMenu.bgbh,
            yljgbm: this.oneItemMenu.yljgbm,
            page: 1,
            limit: 10
          })
        } else {
          this.tableData = []
        }
      },
      deep: true,
      immediate: true
    }
  },
  created() {},
  methods: {
    getList() {
      this.getPatientExamRegistrationInfoCheckList({
        // bgbh: '008',
        bgbh: this.oneItemMenu.bgbh,
        yljgbm: this.oneItemMenu.yljgbm,
        ...this.listQuery
      })
    },
    getPatientExamRegistrationInfoCheckList(params) {
      this.loadingModel('正在查询数据...')
      getPatientExamRegistrationInfoCheckList(params).then((res) => {
        const { data } = res
        const { list, total } = data
        this.tableData = list
        this.total = total
        this.loadingModelObj.close()
      }).catch(() => {
        this.loadingModelObj.close()
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
